package c.c.b.a.b.a.a;

import c.c.b.a.a.e;
import c.c.b.a.a.f;
import c.c.b.a.a.g;
import c.c.b.a.a.w;
import c.c.b.a.a.x;
import java.io.IOException;
import java.util.concurrent.TimeUnit;

/* compiled from: CacheInterceptor */
public class a implements w {
    public boolean a;
    public final /* synthetic */ g b;
    public final /* synthetic */ c c;
    public final /* synthetic */ f d;

    public a(b bVar, g gVar, c cVar, f fVar) {
        this.b = gVar;
        this.c = cVar;
        this.d = fVar;
    }

    public x a() {
        return this.b.a();
    }

    public long b(e eVar, long j) throws IOException {
        try {
            j = this.b.b(eVar, j);
            if (j == -1) {
                if (!this.a) {
                    this.a = true;
                    this.d.close();
                }
                return -1;
            }
            eVar.r(this.d.c(), eVar.b - j, j);
            this.d.u();
            return j;
        } catch (IOException e) {
            if (!this.a) {
                this.a = true;
                this.c.b();
            }
            throw e;
        }
    }

    public void close() throws IOException {
        if (!(this.a || c.c.b.a.b.a.e.p(this, 100, TimeUnit.MILLISECONDS))) {
            this.a = true;
            this.c.b();
        }
        this.b.close();
    }
}
